import {createSlice} from '@reduxjs/toolkit'

const collectSlice=createSlice({
    name:'collectNS',
    initialState:{
        collectList:[]
    },
    reducers:{
        addCollect(state,action){
            console.log('---------加入收藏---------------');
            const isExist=state.collectList.find(item=>item.id==action.payload.id)
            if(!isExist){
                state.collectList.push(action.payload)
            }
           
        }
    }
})
export const {addCollect}=collectSlice.actions
export default collectSlice.reducer
